<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <span
          style="color: red;">说明：1.本表要与基本收支人员经费相对应；2.上半年退休人员按退休人员填列，下半年退休按在职人员填列，但预算支出分别按实际在职月份与退休月份进行测算；2.变动原因：例如：姓名+*月份退休，姓名+*月份离职（调出科学院）、姓名+*月份院内调动（调入单位）。
        </span>
        <a-row>
          <a-col :span="10">
            <a-form-model-item label="年度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="year">
              <j-dict-select-tag type="list" v-model="model.year" dictCode="year" placeholder="请选择年度"
                @change="handleYearChange" />
            </a-form-model-item>
          </a-col>

          <!-- 7月末/12月末人事数据 -->
          <a-col :span="24" style="margin-bottom: 16px;">
            <a-card title="7月末/12月末人事数据" bordered
              :style="{ boxShadow: '0 1px 2px -2px rgba(0,0,0,0.16), 0 3px 6px 0 rgba(0,0,0,0.12)' }">
              <a-row :gutter="24">
                <a-col :span="24" style="margin-bottom: 16px;">
                  <a-card title="在职人员" bordered
                    :style="{ boxShadow: '0 1px 2px -2px rgba(0,0,0,0.16), 0 3px 6px 0 rgba(0,0,0,0.12)' }">
                    <a-row :gutter="16">
                      <a-col :span="16">
                        <a-form-model-item label="在编人员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cwZbry">
                          <a-input-number v-model="model.cwZbry" placeholder="请输入7月末在编人员" style="width: 100%" />
                        </a-form-model-item>
                      </a-col>
                      <a-col :span="16">
                        <a-form-model-item label="院派遣人员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cwYpqry">
                          <a-input-number v-model="model.cwYpqry" placeholder="请输入7月末院派遣人员" style="width: 100%" />
                        </a-form-model-item>
                      </a-col>
                      <a-col :span="16">
                        <a-form-model-item label="所派遣人员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cwSpqry">
                          <a-input-number v-model="model.cwSpqry" placeholder="请输入7月末所派遣人员" style="width: 100%" />
                        </a-form-model-item>
                      </a-col>

                      <a-col :span="22">
                        <a-form-model-item label="借调人员/返聘人员" :labelCol="labelCol" :wrapperCol="wrapperCol"
                          prop="cwJdry">
                          <a-input-number v-model="model.cwJdry" placeholder="请输入7月末借调/返聘人员" />
                        </a-form-model-item>
                      </a-col>
                    </a-row>
                  </a-card>
                </a-col>
                <a-col :span="12">
                  <a-form-model-item label="离休人员" :labelCol="labelCol" :wrapperCol="wrapperCol"
                    prop="cwRetiredVeterans">
                    <a-input-number v-model="model.cwRetiredVeterans" placeholder="请输入7月末离休人员" style="width: 100%" />
                  </a-form-model-item>
                </a-col>
                <a-col :span="12">
                  <a-form-model-item label="退休人员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cwRetiree">
                    <a-input-number v-model="model.cwRetiree" placeholder="请输入7月末退休人员" style="width: 100%" />
                  </a-form-model-item>
                </a-col>
              </a-row>
            </a-card>
          </a-col>
          <!-- 7月末/12月末人事数据 -->
          <a-col :span="24" style="margin-bottom: 16px;">
            <a-card title="预算人员情况" bordered
              :style="{ boxShadow: '0 1px 2px -2px rgba(0,0,0,0.16), 0 3px 6px 0 rgba(0,0,0,0.12)' }">
              <a-row :gutter="24">
                <a-col :span="24" style="margin-bottom: 16px;">
                  <a-card title="在职人员" bordered
                    :style="{ boxShadow: '0 1px 2px -2px rgba(0,0,0,0.16), 0 3px 6px 0 rgba(0,0,0,0.12)' }">
                    <a-row :gutter="16">
                      <a-col :span="24" style="margin-bottom: 16px;">
                        <a-card title="在编人员" bordered
                          :style="{ boxShadow: '0 1px 2px -2px rgba(0,0,0,0.16), 0 3px 6px 0 rgba(0,0,0,0.12)' }">
                          <a-row :gutter="16">
                            <a-col :span="12">
                              <a-form-model-item label="预算人数" :labelCol="labelCol" :wrapperCol="wrapperCol"
                                prop="cwYsrs">
                                <a-input-number v-model="model.cwYsrs" placeholder="请输入预算人数" style="width: 100%"
                                  :max="999" />
                              </a-form-model-item>
                            </a-col>
                            <a-col :span="12">
                              <a-form-model-item label="增加人数" :labelCol="labelCol" :wrapperCol="wrapperCol"
                                prop="cwZjrs">
                                <a-input-number v-model="model.cwZjrs" placeholder="请输入增加人数" style="width: 100%" />
                              </a-form-model-item>
                            </a-col>
                            <a-col :span="12">
                              <a-form-model-item label="减少人数" :labelCol="labelCol" :wrapperCol="wrapperCol"
                                prop="cwJsrs">
                                <a-input-number v-model="model.cwJsrs" placeholder="请输入减少人数" style="width: 100%" />
                              </a-form-model-item>
                            </a-col>
                            <a-col :span="12">
                              <a-form-model-item label="变动原因" :labelCol="labelCol" :wrapperCol="wrapperCol"
                                prop="cwBdyy">
                                <a-input v-model="model.cwBdyy" placeholder="请输入变动原因"></a-input>
                              </a-form-model-item>
                            </a-col>
                          </a-row>
                        </a-card>
                      </a-col>
                      <a-col :span="24" style="margin-bottom: 16px;">
                        <a-card title="院派遣人员" bordered
                          :style="{ boxShadow: '0 1px 2px -2px rgba(0,0,0,0.16), 0 3px 6px 0 rgba(0,0,0,0.12)' }">
                          <a-row :gutter="16">
                            <a-col :span="12">
                              <a-form-model-item label="预算人数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ysrs">
                                <a-input-number v-model="model.ysrs" placeholder="请输入预算人数" style="width: 100%" />
                              </a-form-model-item>
                            </a-col>
                            <a-col :span="12">
                              <a-form-model-item label="增加人数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zjrs">
                                <a-input-number v-model="model.zjrs" placeholder="请输入增加人数" style="width: 100%" />
                              </a-form-model-item>
                            </a-col>
                            <a-col :span="12">
                              <a-form-model-item label="减少人数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jsrs">
                                <a-input-number v-model="model.jsrs" placeholder="请输入减少人数" style="width: 100%" />
                              </a-form-model-item>
                            </a-col>
                            <a-col :span="12">
                              <a-form-model-item label="变动原因" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bdyy">
                                <a-input v-model="model.bdyy" placeholder="请输入变动原因"></a-input>
                              </a-form-model-item>
                            </a-col>
                          </a-row>
                        </a-card>
                      </a-col>
                      <a-col :span="24" style="margin-bottom: 16px;">
                        <a-card title="所派遣人员" bordered
                          :style="{ boxShadow: '0 1px 2px -2px rgba(0,0,0,0.16), 0 3px 6px 0 rgba(0,0,0,0.12)' }">
                          <a-row :gutter="16">
                            <a-col :span="12">
                              <a-form-model-item label="预算人数" :labelCol="labelCol" :wrapperCol="wrapperCol"
                                prop="cwSYsrs">
                                <a-input-number v-model="model.cwSYsrs" placeholder="请输入预算人数" style="width: 100%" />
                              </a-form-model-item>
                            </a-col>
                            <a-col :span="12">
                              <a-form-model-item label="增加人数" :labelCol="labelCol" :wrapperCol="wrapperCol"
                                prop="cwSZjrs">
                                <a-input-number v-model="model.cwSZjrs" placeholder="请输入增加人数" style="width: 100%" />
                              </a-form-model-item>
                            </a-col>
                            <a-col :span="12">
                              <a-form-model-item label="减少人数" :labelCol="labelCol" :wrapperCol="wrapperCol"
                                prop="cwSJsrs">
                                <a-input-number v-model="model.cwSJsrs" placeholder="请输入减少人数" style="width: 100%" />
                              </a-form-model-item>
                            </a-col>
                            <a-col :span="12">
                              <a-form-model-item label="变动原因" :labelCol="labelCol" :wrapperCol="wrapperCol"
                                prop="cwSBdyy">
                                <a-input v-model="model.cwSBdyy" placeholder="请输入变动原因"></a-input>
                              </a-form-model-item>
                            </a-col>
                          </a-row>
                        </a-card>
                      </a-col>
                    </a-row>
                  </a-card>
                </a-col>

              </a-row>

              <a-col :span="25">
                <a-form-model-item label="借调人员/返聘人员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cwSJdry">
                  <a-input-number v-model="model.cwSJdry" placeholder="请输入借调人员/返聘人员" />
                </a-form-model-item>
              </a-col>
            </a-card>
          </a-col>
          <!--          &lt;!&ndash; 预算人员情况 &ndash;&gt;-->
          <!--          <a-col :span="24" style="margin-bottom: 16px;">-->
          <!--            <a-card title="预算人员情况" bordered-->
          <!--              :style="{ boxShadow: '0 1px 2px -2px rgba(0,0,0,0.16), 0 3px 6px 0 rgba(0,0,0,0.12)' }">-->
          <!--              <a-row :gutter="16">-->
          <!--                <a-col :span="24" style="margin-bottom: 16px;">-->
          <!--                  <a-card title="在职人员" bordered-->
          <!--                    :style="{ boxShadow: '0 1px 2px -2px rgba(0,0,0,0.16), 0 3px 6px 0 rgba(0,0,0,0.12)' }">-->
          <!--                    <a-row :gutter="16">-->
          <!--                      <a-col :span="24" style="margin-bottom: 16px;">-->
          <!--                        <a-card title="在编人员" bordered-->
          <!--                          :style="{ boxShadow: '0 1px 2px -2px rgba(0,0,0,0.16), 0 3px 6px 0 rgba(0,0,0,0.12)' }">-->
          <!--                          <a-row :gutter="16">-->
          <!--                            <a-col :span="12">-->
          <!--                              <a-form-model-item label="预算人数" :labelCol="labelCol" :wrapperCol="wrapperCol"-->
          <!--                                prop="cwYsrs">-->
          <!--                                <a-input-number v-model="model.cwYsrs" placeholder="请输入预算人数" style="width: 100%" max="999" />-->
          <!--                              </a-form-model-item>-->
          <!--                            </a-col>-->
          <!--                            <a-col :span="12">-->
          <!--                              <a-form-model-item label="增加人数" :labelCol="labelCol" :wrapperCol="wrapperCol"-->
          <!--                                prop="cwZjrs">-->
          <!--                                <a-input-number v-model="model.cwZjrs" placeholder="请输入增加人数" style="width: 100%" />-->
          <!--                              </a-form-model-item>-->
          <!--                            </a-col>-->
          <!--                            <a-col :span="12">-->
          <!--                              <a-form-model-item label="减少人数" :labelCol="labelCol" :wrapperCol="wrapperCol"-->
          <!--                                prop="cwJsrs">-->
          <!--                                <a-input-number v-model="model.cwJsrs" placeholder="请输入减少人数" style="width: 100%" />-->
          <!--                              </a-form-model-item>-->
          <!--                            </a-col>-->
          <!--                            <a-col :span="12">-->
          <!--                              <a-form-model-item label="变动原因" :labelCol="labelCol" :wrapperCol="wrapperCol"-->
          <!--                                prop="cwBdyy">-->
          <!--                                <a-input v-model="model.cwBdyy" placeholder="请输入变动原因"></a-input>-->
          <!--                              </a-form-model-item>-->
          <!--                            </a-col>-->
          <!--                          </a-row>-->
          <!--                        </a-card>-->
          <!--                      </a-col>-->
          <!--                      <a-col :span="24" style="margin-bottom: 16px;">-->
          <!--                        <a-card title="院派遣人员" bordered-->
          <!--                          :style="{ boxShadow: '0 1px 2px -2px rgba(0,0,0,0.16), 0 3px 6px 0 rgba(0,0,0,0.12)' }">-->
          <!--                          <a-row :gutter="16">-->
          <!--                            <a-col :span="12">-->
          <!--                              <a-form-model-item label="预算人数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ysrs">-->
          <!--                                <a-input-number v-model="model.ysrs" placeholder="请输入预算人数" style="width: 100%" />-->
          <!--                              </a-form-model-item>-->
          <!--                            </a-col>-->
          <!--                            <a-col :span="12">-->
          <!--                              <a-form-model-item label="增加人数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zjrs">-->
          <!--                                <a-input-number v-model="model.zjrs" placeholder="请输入增加人数" style="width: 100%" />-->
          <!--                              </a-form-model-item>-->
          <!--                            </a-col>-->
          <!--                            <a-col :span="12">-->
          <!--                              <a-form-model-item label="减少人数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jsrs">-->
          <!--                                <a-input-number v-model="model.jsrs" placeholder="请输入减少人数" style="width: 100%" />-->
          <!--                              </a-form-model-item>-->
          <!--                            </a-col>-->
          <!--                            <a-col :span="12">-->
          <!--                              <a-form-model-item label="变动原因" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bdyy">-->
          <!--                                <a-input v-model="model.bdyy" placeholder="请输入变动原因"></a-input>-->
          <!--                              </a-form-model-item>-->
          <!--                            </a-col>-->
          <!--                          </a-row>-->
          <!--                        </a-card>-->
          <!--                      </a-col>-->
          <!--                      <a-col :span="24" style="margin-bottom: 16px;">-->
          <!--                        <a-card title="所派遣人员" bordered-->
          <!--                          :style="{ boxShadow: '0 1px 2px -2px rgba(0,0,0,0.16), 0 3px 6px 0 rgba(0,0,0,0.12)' }">-->
          <!--                          <a-row :gutter="16">-->
          <!--                            <a-col :span="12">-->
          <!--                              <a-form-model-item label="预算人数" :labelCol="labelCol" :wrapperCol="wrapperCol"-->
          <!--                                prop="cwSYsrs">-->
          <!--                                <a-input-number v-model="model.cwSYsrs" placeholder="请输入预算人数" style="width: 100%" />-->
          <!--                              </a-form-model-item>-->
          <!--                            </a-col>-->
          <!--                            <a-col :span="12">-->
          <!--                              <a-form-model-item label="增加人数" :labelCol="labelCol" :wrapperCol="wrapperCol"-->
          <!--                                prop="cwSZjrs">-->
          <!--                                <a-input-number v-model="model.cwSZjrs" placeholder="请输入增加人数" style="width: 100%" />-->
          <!--                              </a-form-model-item>-->
          <!--                            </a-col>-->
          <!--                            <a-col :span="12">-->
          <!--                              <a-form-model-item label="减少人数" :labelCol="labelCol" :wrapperCol="wrapperCol"-->
          <!--                                prop="cwSJsrs">-->
          <!--                                <a-input-number v-model="model.cwSJsrs" placeholder="请输入减少人数" style="width: 100%" />-->
          <!--                              </a-form-model-item>-->
          <!--                            </a-col>-->
          <!--                            <a-col :span="12">-->
          <!--                              <a-form-model-item label="变动原因" :labelCol="labelCol" :wrapperCol="wrapperCol"-->
          <!--                                prop="cwSBdyy">-->
          <!--                                <a-input v-model="model.cwSBdyy" placeholder="请输入变动原因"></a-input>-->
          <!--                              </a-form-model-item>-->
          <!--                            </a-col>-->
          <!--                          </a-row>-->
          <!--                        </a-card>-->
          <!--                      </a-col>-->
          <!--                      <a-col :span="25">-->
          <!--                        <a-form-model-item label="借调人员/返聘人员" :labelCol="labelCol" :wrapperCol="wrapperCol"-->
          <!--                          prop="cwSJdry">-->
          <!--                          <a-input-number v-model="model.cwSJdry" placeholder="请输入借调人员/返聘人员" />-->
          <!--                        </a-form-model-item>-->
          <!--                      </a-col>-->
          <!--                    </a-row>-->
          <!--                  </a-card>-->
          <!--                </a-col>-->
          <a-col :span="12">
            <a-form-model-item label="离休人员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cwLxry">
              <a-input-number v-model="model.cwLxry" placeholder="请输入离休人员" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24" style="margin-bottom: 16px;">
            <a-card title="退休人员" bordered
              :style="{ boxShadow: '0 1px 2px -2px rgba(0,0,0,0.16), 0 3px 6px 0 rgba(0,0,0,0.12)' }">
              <a-row :gutter="16">
                <a-col :span="12">
                  <a-form-model-item label="预算人数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cwTxYsrs">
                    <a-input-number v-model="model.cwTxYsrs" placeholder="请输入预算人数" style="width: 100%" />
                  </a-form-model-item>
                </a-col>
                <a-col :span="12">
                  <a-form-model-item label="增加人数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cwTxZjrs">
                    <a-input-number v-model="model.cwTxZjrs" placeholder="请输入增加人数" style="width: 100%" />
                   </a-form-model-item>
                  </a-col>
                </a-row>
              </a-card>
            </a-col>
          </a-row>
        </a-card>
        </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>
import { mapState } from 'vuex'

import { httpAction, getAction } from '@/api/manage'
import { validateDuplicateValue } from '@/utils/util'

export default {
  name: 'CwYsryqkmxForm',
  components: {},
  props: {
    disabled: {
      type: Boolean,
      default: false,
      required: false
    },
    scene: { // 接收 Modal 传递的场景值
      type: String,
      default: ''
    }
  },
  data() {
    return {
      model: { year: '' }, // 初始为空，由watch同步全局年度
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      confirmLoading: false,
      validatorRules: {
        cwZbry: [
          { required: false },
          { pattern: /^\d{0,4}$/, message: '请输入0-4整数!!' },
        ],
        cwSJdry: [
          { required: false },
          { pattern: /^\d{0,4}$/, message: '请输入0-4整数!!' },
        ],
        cwJdry: [
          { required: false },
          { pattern: /^\d{0,4}$/, message: '请输入0-4整数!!' },
        ],
        cwYpqry: [
          { required: false },
          { pattern: /^\d{0,4}$/, message: '请输入0-4整数!!' },
        ],
        cwSpqry: [
          { required: false },
          { pattern: /^\d{0,4}$/, message: '请输入0-4整数!!' },
        ],
        cwRetiredVeterans: [
          { required: false },
          { pattern: /^\d{0,4}$/, message: '请输入0-4整数!!' },
        ],
        cwRetiree: [
          { required: false },
          { pattern: /^\d{0,4}$/, message: '请输入0-4整数!!' },
        ],
        cwYsrs: [
          { required: false },
          { pattern: /^\d{0,4}$/, message: '请输入0-4整数!!' },
        ],
        cwZjrs: [
          { required: false },
          { pattern: /^\d{0,4}$/, message: '请输入0-4整数!!' },
        ],
        cwJsrs: [
          { required: false },
          { pattern: /^\d{0,4}$/, message: '请输入0-4整数!!' },
        ],
        ysrs: [
          { required: false },
          { pattern: /^\d{0,4}$/, message: '请输入0-4整数!!' },
        ],
        zjrs: [
          { required: false },
          { pattern: /^\d{0,4}$/, message: '请输入0-4整数!!' },
        ],
        jsrs: [
          { required: false },
          { pattern: /^\d{0,4}$/, message: '请输入0-4整数!!' },
        ],
        cwSYsrs: [
          { required: false },
          { pattern: /^\d{0,4}$/, message: '请输入0-4整数!!' },
        ],
        cwSZjrs: [
          { required: false },
          { pattern: /^\d{0,4}$/, message: '请输入0-4整数!!' },
        ],
        cwSJsrs: [
          { required: false },
          { pattern: /^\d{0,4}$/, message: '请输入0-4整数!!' },
        ],
        cwLxry: [
          { required: false },
          { pattern: /^\d{0,4}$/, message: '请输入0-4整数!!' },
        ],
        cwTxYsrs: [
          { required: false },
          { pattern: /^\d{0,4}$/, message: '请输入0-4整数!' },
        ],
        cwTxZjrs: [
          { required: false },
          { pattern: /^\d{0,4}$/, message: '请输入0-4整数!' },
        ],
      },
      url: {
        add: "/cw/cwYsryqkmx/add",
        edit: "/cw/cwYsryqkmx/edit",
        queryById: "/cw/cwYsryqkmx/queryById",
        queryByYear: "/cw/cwYsryqkmx/queryByYear", // 新增：按年度查询接口
      },
      isManualChange: false, // 标记是否手动修改过表单年度

      modelDefault: {}
    }
  },
  computed: {
    formDisabled() {
      return this.disabled
    },
    ...mapState({ globalYear: state => state.app.globalYear })

  },
  watch: {
    // 监听全局年度变化，同步到表单（仅当未手动修改时）
    globalYear(newVal) {
      if (!this.isManualChange) {
        this.model.year = newVal
        // 可选：自动触发年度查询，解开注释即可
        // this.handleYearChange(newVal)
      }
    },
    // 监听表单年度变化，标记是否手动修改
    'model.year'(newVal, oldVal) {
      if (oldVal && newVal !== this.globalYear) {
        this.isManualChange = true // 手动修改后，不再同步全局年度
      }
    }
  },
  created() {
    this.model.year = this.globalYear
    this.modelDefault = JSON.parse(JSON.stringify(this.model));
    const scene = this.scene; // 接收 Modal 传递的 scene（add/edit）
    this.currentScene = scene; // 存储到本地变量，后续复用
    if (scene=='add'){
      this. handleYearChange(this.model.year)
    }
  },
  methods: {
    add() {
      this.edit(this.modelDefault);
    },
    edit(record) {
      // 重置表单验证状态
      this.$nextTick(() => {
        if (this.$refs.form) {
          this.$refs.form.clearValidate();
        }
      });
      this.model = Object.assign({}, record);
      // 确保弹窗可见（如果使用弹窗）
      if (this.hasOwnProperty('visible')) {
        this.visible = true;
      }
    },
    // 年度选择变化处理
    handleYearChange(selectedYear) {
      // 未选择年度时重置表单
      if (!selectedYear) {
        this.add();
        return;
      }

      this.confirmLoading = true;
      // 调用按年度查询接口
      getAction(this.url.queryByYear, { year: selectedYear })
        .then(res => {
          if (res.success) {
            const data = res.result;
            if (data && data.id) {
              // 存在数据，进入编辑模式
              this.edit(data);
              this.$message.info(`已加载${selectedYear}年度数据，可直接编辑`);
            } else {
              // 不存在数据，保持新增模式
              console.log(this.model.year, "年度")

              this.add();
              this.model.year = selectedYear
              this.$message.info(`未查询到${selectedYear}年度数据，将创建新数据`);
            }
          } else {
            this.add();
            this.$message.error(`查询失败：${res.message}`);
          }
        })
        .catch(err => {
          this.add();
          this.$message.error(`网络异常：${err.message || '请稍后重试'}`);
        })
        .finally(() => {
          this.confirmLoading = false;
        });
    },
    submitForm() {
      const that = this;
      this.$refs.form.validate(valid => {
        if (valid) {
          that.confirmLoading = true;
          let httpurl = '';
          let method = '';
          if (!this.model.id) {
            httpurl += this.url.add;
            method = 'post';
          } else {
            httpurl += this.url.edit;
            method = 'put';
          }
          httpAction(httpurl, this.model, method).then(res => {
            if (res.success) {
              that.$message.success(res.message);
              that.$emit('ok');
            } else {
              that.$message.warning(res.message);
            }
          }).finally(() => {
            that.confirmLoading = false;
          });
        }
      });
    }
  }
}
</script>